package com.game.modular.game.battle.info.roundInfo.dto.messageDto;

import com.game.modular.game.battle.info.roundInfo.domain.PvpBattleStatisticsInfo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

import java.util.*;

@Data
@AllArgsConstructor
@Builder
public class PvpMessageDto {
    @ApiModelProperty
    private PvpBattleStatisticsInfo pvpBattleStatisticsInfoList;

    /**
     * 获取胜利者id
     *
     * @param pvpBattleStatisticsInfoList
     * @return
     */
    public static Long obtainWinnerPlayerId(List<PvpBattleStatisticsInfo> pvpBattleStatisticsInfoList) {
        Long winPlayerId = null;
        // id倒序
        if (pvpBattleStatisticsInfoList.isEmpty()) {
            return winPlayerId;
        }
        pvpBattleStatisticsInfoList.sort(Comparator.comparing(PvpBattleStatisticsInfo::getBattleId).reversed());
        winPlayerId = pvpBattleStatisticsInfoList.get(0).getWinPlayerId();
        return winPlayerId;
    }
}
